package com.itheima.reggie.common;

/**
 * 基于 threadLocal 封装工具类 用户保存 和 获取当前登入用户 id
 */
public class BaseContext {
    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();
    //获取用户id
    public static void setUserId(Long id){
        threadLocal.set(id);
    }
    //保存用户id
    public static Long getUserId(){
        return threadLocal.get();
    }

    //获取用户id
    public static void setCurrentId(Long id){
        threadLocal.set(id);
    }
    //保存用户id
    public static Long getCurrentId(){
        return threadLocal.get();
    }
}
